const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Order = sequelize.define('Order', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    woo_id: {
        type: DataTypes.INTEGER,
        unique: true,
        allowNull: false
    },
    customer_email: {
        type: DataTypes.STRING,
        allowNull: false
    },
    total_amount: {
        type: DataTypes.DECIMAL(10, 2),
        allowNull: false
    },
    status: {
        type: DataTypes.ENUM('pending', 'processing', 'completed', 'cancelled', 'refunded'),
        defaultValue: 'pending'
    },
    order_date: {
        type: DataTypes.DATE,
        allowNull: false
    },
    items: {
        type: DataTypes.JSON
    },
    shipping_address: {
        type: DataTypes.JSON
    },
    billing_address: {
        type: DataTypes.JSON
    }
});

module.exports = Order;
